<template>
	<view>
		<view v-for="(item, index) in psList" :key="index">
			<view class="order">
				<view>{{ item.name }}</view>
				<button type="default" @click="choose(item.url)" :style="{ borderRadius: '30rpx', backgroundColor: '#FEB140', fontSize: '24rpx', margin: '0 30rpx 0 0' }">
					选择
				</button>
			</view>
		</view>
	</view>
</template>

<script>
import { Storage } from '@/static/libs/utils';
export default {
	data() {
		return {
			token: '',
			dd: '',
			psList: [
				{ name: '达达配送', url: 'push_dada' },
				{ name: 'UU跑腿配送', url: 'push_uupaotui' },
				{ name: '闪送配送', url: 'push_ishansong' },
				{ name: '点我达配送', url: 'push_dianwoda' },
				{ name: '顺丰同城配送', url: 'push_sfexpress' },
				{ name: '蜂鸟配送', url: 'push_fengniao' }
			]
		};
	},
	onLoad(option) {
		this.token = Storage.get('token');
		console.log(option.id);
		this.dd = JSON.parse(option.id);
	},
	methods: {
		choose(url) {
			// console.log(url);
			this.$request
				.post(`/waimai_go/web/wmerchant.php?c=site&a=entry&ctrl=store&ac=order&op=takeout&ta=${url}&do=web&m=we7_wmall&i=1&token=${this.token}&isajax=1`, { id: this.dd })
				.then(res => {
					// console.log(res);
					if (res.data.message.errno == 0) {
						uni.showToast({
							title: res.data.message.message,
							icon: 'success', //如果要纯文本，不要icon，将值设为'none'
							duration: 1500
						});
					} else {
						uni.showToast({
							title: res.data.message.message,
							icon: 'none', //如果要纯文本，不要icon，将值设为'none'
							duration: 2000 //持续时间为 2秒
						});
					}
				});
		}
	}
};
</script>

<style lang="scss">
.order {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin: 30rpx;
	line-height: 70rpx;
	border: 1rpx solid #f1f1f1;
	border-radius: 15rpx;
	padding: 20rpx;
}
</style>
